package com.gmlive.common.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.view.Window;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.gmlive.common.ui.R;

public class IkLoadingDialog extends BaseDialog {

    public IkLoadingDialog(@NonNull Context context) {
        this(context, 0);
    }

    public IkLoadingDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public IkLoadingDialog(@NonNull Context context, boolean cancelable, @Nullable DialogInterface.OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public void init() {
        setContentView(R.layout.ik_loading_dialog);
        Window window = getWindow();
        if (null != window)
            window.setBackgroundDrawable(null);
    }

    public static class Builder {

        private Context mContext;

        private boolean cancelable;

        public Builder(Context context) {
            mContext = context;
        }

        public Builder setCancelable(boolean b){
            cancelable = b;
            return this;
        }

        public IkLoadingDialog show() {
            IkLoadingDialog dialog = new IkLoadingDialog(mContext);
            dialog.init();
            dialog.setCancelable(cancelable);
            dialog.show();
            return dialog;
        }
    }

}
